package testjava;

import java.io.FileInputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServlet extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        ServletOutputStream sos = resp.getOutputStream();
        FileInputStream fis = new FileInputStream(
                "C:/training/project/testjava/WebContent/image/image1.jpg");
        byte[] buf = new byte[100];
        int len = 0;
        while ((len = fis.read(buf)) != -1) {
            sos.write(buf, 0, len);
        }
        sos.flush();
        sos.close();
        fis.close();
    }

}
